package com.bsj.power.common.def.dto.job;

import com.bsj.power.common.def.dto.PageDTO;
import com.bsj.power.common.def.entity.job.SysJob;
import lombok.Data;

import java.util.Date;

/**
 * @author yinhao
 * @version 1.0
 * @description
 * @date 2024/1/24
 */
@Data
public class SysJobDTO extends PageDTO {

    /**
     * 任务序号
     */
    private Long jobId;
    /**
     * 任务名称
     */
    private String jobName;
    /**
     * 任务组名
     */
    private String jobGroup;
    /**
     * 调用目标字符串
     */
    private String invokeTarget;
    /**
     * 执行表达式
     */
    private String cronExpression;
    /**
     * 计划策略 0：默认 1:立即触发执行 2:触发一次执行 3:不触发立即执行
     */
    private Integer misfirePolicy;
    /**
     * 是否并发执行 0:允许 1:禁止
     */
    private Integer concurrent;
    /**
     * 任务状态 0: 正常 1:暂停
     */
    private Integer status;
    /**
     * 创建人
     */
    private Long userId;
    /**
     * 摄像头id（英文逗号相隔）
     */
    private String deviceId;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新时间
     */
    private Date updateTime;
    /**
     * 备注
     */
    private String notes;

    public SysJob change() {
        SysJob sysJob = new SysJob();
        if (this.jobId != null) {
            sysJob.setJobId(this.jobId);
        }
        if (this.jobGroup != null) {
            sysJob.setJobGroup(this.jobGroup);
        }
        if (this.jobName != null) {
            sysJob.setJobName(this.jobName);
        }
        if (this.invokeTarget != null) {
            sysJob.setInvokeTarget(this.invokeTarget);
        }
        if (this.cronExpression != null) {
            sysJob.setCronExpression(this.cronExpression);
        }
        if (this.misfirePolicy != null) {
            sysJob.setMisfirePolicy(this.misfirePolicy);
        }
        if (this.concurrent != null) {
            sysJob.setConcurrent(this.concurrent);
        }
        if (this.status != null) {
            sysJob.setStatus(this.status);
        }
        if (this.userId != null) {
            sysJob.setUserId(this.userId);
        }
        if (this.notes != null) {
            sysJob.setNotes(this.notes);
        }
        return sysJob;
    }
}
